<template>
	<view>
		<u-empty v-if="listData.length < 1" mode="data" text="暂无数据" icon="/static/empty/data.png"></u-empty>
		<view class="lb-list" v-for="(item,index) in listData" :key="index">
			<view class="lb-item">
				<view class="lb-left">
					<image src="/static/icon/list-m.png" mode=""></image>
				</view>
				<view class="lb-right">
					<view class="lb-tip">
						<view class="lb-name">
							提现
						</view>
						<view class="lb-time">
							{{item.createtime}}
						</view>
					</view>
					<view class="lb-price">
						{{item.amount}}
					</view>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {
		distributionApiCashLog
	} from "@/api/apis/retail.js"
	export default {
		data() {
			return {
				page: 1,
				limit: 10,
				listData: [],
				isLoading: false
			}
		},
		methods: {
			//列表
			getList() {
				uni.showLoading({
					title: "加载中",
					mask: true
				});
				this.isLoading = true;
				distributionApiCashLog({
					page: this.page,
					limit: this.limit,
				}).then(res => {
					uni.hideLoading();
					let data = res.data;
					if (this.page == 1) {
						this.listData = data.data;
					} else {
						this.listData = this.listData.concat(data.data);
					}
					if (data.total > this.page * this.limit) {
						// console.log(res.data.length)
						//请求成功 节流阀 设置为false（没有走完函数不允许再次请求）
						this.isLoading = false;
						this.page++;
					}
				})
			},
		},
		onLoad() {
			this.getList();
		},
		onReachBottom() {
			//注意 这里是重要的一步，不满足条件下拉加载不能继续请求数据
			if (!this.isLoading) {
				this.getList();
			}

		},
	}
</script>

<style lang="scss">
	//列表
	.lb-list {
		display: flex;
		background: rgba(255, 255, 255, 1);
		border-top: 2rpx solid #F5F5F5;
		box-sizing: border-box;


		.lb-item {
			width: 100%;
			display: flex;



			display: flex;
			padding: 26rpx 32rpx 26rpx 24rpx;

			.lb-left {
				width: 76rpx;
				height: 76rpx;
			}

			.lb-right {
				display: flex;
				width: calc(100% - 80rpx);
				justify-content: space-between;
				align-items: center;

				.lb-tip {
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					padding-left: 24rpx;

					.lb-name {
						font-size: $main-font-28;
						color: $main-font-color;
					}

					.lb-time {
						font-size: $main-font-28;
						color: $main-font-color-grey9;
						margin-top: 12rpx;
					}
				}

				.lb-price {
					font-size: $main-font-28;
					color: #F65D40;

					&::before {
						content: '¥ ';
						font-size: $main-font-24;
					}
				}


			}


		}

	}
</style>